// pages/question/index.js
import tool from "../../utils/tool.js";
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    inputvalue:'',
    orderdata:[],
    lengt:0,
    isindata:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.request({
      url: app.globalData.url+'/zkxj/question/list',
      data: {
        "comOrUser": this.data.isindata,
        "currPage": 1,
        "pageSize": 100,
        "checkStatus": 1,
      },
      method: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      success: (res) => {
       console.log(res.data.data.list);
       this.setData({
        orderdata:res.data.data.list,
        lengt:res.data.data.length
       })
       console.log(this.data.lengt);
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  handletodeta(e){
    const queid = e.currentTarget.dataset['index'] 
    console.log(queid);
    wx.navigateTo({
      url: `/pages/questdetail/index?id=${queid}`,
    })
  },
  handlechecks(){
    this.setData({
  isindata:0
})
wx.request({
  url: app.globalData.url+'/zkxj/question/list',
  data: {
    "comOrUser": this.data.isindata,
    "currPage": 1,
    "pageSize": 100,
    "checkStatus": 1,
  },
  method: 'post',
  header: {
    'content-type': 'application/json',
    'token': wx.getStorageSync('token')
  },
  success: (res) => {
   console.log(res.data.data.list);
   this.setData({
    orderdata:res.data.data.list,
    lengt:res.data.data.length
   })
   console.log(this.data.lengt);
  },
}) 
  },
  handlecheckss(){
    this.setData({
      isindata:1
    })
    wx.request({
      url: app.globalData.url+'/zkxj/question/list',
      data: {
        "comOrUser": this.data.isindata,
        "currPage": 1,
        "pageSize": 100,
        "checkStatus": 1,
      },
      method: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      success: (res) => {
       console.log(res.data.data.list);
       this.setData({
        orderdata:res.data.data.list,
        lengt:res.data.data.length
       })
       console.log(this.data.lengt);
      },
    })
  },
  handletodetai(e){
    const queid = e.currentTarget.dataset['index'] 
    console.log(queid);
    wx.navigateTo({
      url: `/pages/questdetail/index?id=${queid}`,
    })
  },
  handletopup(){
    wx.navigateTo({
      url: `/pages/problemup/index`,
    })
  },
  onchangein: tool.throttle(function (e) {  
    console.log(e[0].detail);
    // this.setData({
    //   inputvalue:e.detail
    // })
    wx.request({
      url: app.globalData.url+'/zkxj/question/list',
      data: {
        title:e[0].detail,
        "comOrUser": this.data.isindata,
        "currPage": 1,
        "pageSize": 100,
        "checkStatus": 1,
      },
      method: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      success: (res) => {
      //  console.log(res);
       this.setData({
        orderdata:res.data.data.list,
        lengt:res.data.data.length
       })
      },
    })
  }),
  
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})